import java.util.Random;
import java.util.Scanner;

public class test {

    public static int facSum(int n){
        int sum=0;
        for (int i = 1; i <=n ; i++) {
            sum+=fac(i);
        }
        return sum;
    }

    public static int fac(int n){
        int ret=1;
        for (int i = 1; i <=n ; i++) {
            ret*=i;
        }
        return ret;
    }

    public static void main(String[] args) {
        System.out.println(facSum(5));
    }

    public static int add(int a,int b){
        int ret=a+b;
        return ret;
    }

    public static void main17(String[] args) {
        int x=10;
        int y=20;
        int ret=add(x,y);
        System.out.println(ret);
    }

    //水仙花数
    public static void main16(String[] args) {
        for (int i = 1; i <=999999; i++) {
            //1.计算当前数字i 是一个几位数
            int count=0;
            int temp=i;
            while(temp!=0){
                count++;
                temp/=10;
            }
            temp=i;
            //2.求temp的每一位
            int sum=0;
            while(temp!=0){
                //pow xx的多少次方
                sum+=Math.pow(temp%10,count);
                temp/=10;
            }
            if(sum==i){
                System.out.println(i);
            }
        }
    }

    //球最大公约数，辗转相除
    public static void main15(String[] args) {
        Scanner scan=new Scanner(System.in);
        int a= scan.nextInt();
        int b= scan.nextInt();
        int c=0;
        int d=1;
        while(d!=0){
            c=a%b;
            d=b%c;
        }
        System.out.println(c);
    }

    public static void main14(String[] args) {
        for (int i = 1; i <=9 ; i++) {
            for (int j = 1; j <=i ; j++) {
                System.out.print(i+"*"+j+"="+(i*j)+" ");
            }
            System.out.println();
        }
    }

    public static void main13(String[] args) {
        Scanner scan=new Scanner(System.in);
        System.out.println("请输入数字");
        while(scan.hasNextInt()) {
            int a = scan.nextInt();
            if(a%2!=0){
                System.out.println("是素数");
            }
        }
    }

    public static void main12(String[] args) {
        Scanner scan=new Scanner(System.in);
        Random random=new Random();
        //如果没写数，nextInt的范围是多少
        int randNum=random.nextInt(100);//[0,100)之间所有的随机数
        System.out.println("随机数为"+randNum);
        while(true){
            System.out.println("请输入数字");
            int num=scan.nextInt();
            if(num<randNum){
                System.out.println("猜小了");
            }else if(num==randNum){
                System.out.println("猜对了");
                break;
            }else{
                System.out.println("猜大了");
            }
        }
    }

    public static void main11(String[] args) {
        Scanner scan=new Scanner(System.in);
        while(scan.hasNextInt()) {
            int a = scan.nextInt();
            System.out.println(a);
        }
    }

    public static void main10(String[] args) {
        Scanner scan=new Scanner(System.in);
        System.out.println("请输入您的姓名：");
        //nextLine 读取一行 可能有空格
        String name= scan.nextLine();
        //next是遇到空格结束 不会读空格
        //String name= scan.next();
        System.out.println(name);

        System.out.println("请输入您的年龄：");
        int a=scan.nextInt();
        System.out.println(a);

        System.out.println("请输入您的体重：");
        double h= scan.nextDouble();
        System.out.println(h);

        scan.close();
    }

    public static void main9(String[] args) {
        System.out.println("输出且换行");
        System.out.print("输出不换行");
        System.out.printf("%s\n","格式化输出");

    }

    public static void main8(String[] args) {
        int sum=0;
        for (int i = 1; i <=6 ; i++) {
            int ret=1;
            for (int j = 1; j <=i ; j++) {
                ret*=j;
            }
            sum+=ret;
        }
        System.out.println(sum);
    }

    public static void main7(String[] args) {
        for (int k = 0; k < 10; k++) {
            System.out.println(k);
        }
    }

    //要求用continue
    public static void main6(String[] args) {
        int i=1;
        while(i<=100){
            if(i%15!=0){
                i++;
                continue;
            }
            System.out.println(i);
            i++;
        }
    }

    public static void main5(String[] args) {
        int i=1;
        while(i<=100) {
            if (i % 3 == 0) {
                if (i % 5 == 0) {
                    System.out.print(i+" ");
                }
            }
            i++;
        }
    }

    //计算1！+2！+3!+....+n!
    public static void main4(String[] args) {
        int j=1;
        int i=1;
        int sum=0;
        int ret=1;
        while(j<=5){
            while(i<=j){
                ret*=i;
                i++;
            }
            j++;
            sum+=ret;
        }
        System.out.println(sum);
    }

    public static void main3(String[] args) {
        int n=1;
        int result=0;
        while(n<=100){
            if(n%2==0){
                result+=n;
            }
            n++;
        }
        System.out.println("偶数的和："+result);
    }

    public static void main2(String[] args) {
        int i=1;
        while(i<=10){
            //System.out.println(i);
            System.out.print(i+" ");
            i++;
        }
    }

    /*
    不能做switch的参数的数据类型有哪些？
    long,float,double,boolean
     */
    public static void main1(String[] args){
        int a=10;
        switch(a){
            case 1:
                System.out.println("1");
            case 2:
                System.out.println("2");
                break;
            case 3:
                System.out.println("3");
            default:
                System.out.println("输入有误！");
                break;
        }
    }

    public static void main0(String[] args) {
        // \"hello\"
        System.out.println("\\\"hello\\\"");
    }
}
